package com.sky.mapper;

import com.sky.entity.Dish;
import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Description:套餐关联的菜品dao层
 */
@Mapper
public interface SetMealDishMapper {

    /**
     * 根据菜品ID查询是否关联了套餐
     *
     * @param dishIds
     * @return
     */
    List<Long> getSetMealDishInfo(List<Long> dishIds);

    /**
     * 批量插入菜品
     *
     * @param dishes
     */
    void batchAddDish(List<SetmealDish> dishes);

    //删除套餐菜品关系表中的数据
    @Delete("delete from setmeal_dish where setmeal_id=#{setMealId}")
    void deleteBySetMealId(Long setMealId);

    //批量删除套餐菜品关系表中的数据
    void batchDeleteBySetMealId(List<Long> ids);

    /**
     * 根据套餐ID查询套餐对应的菜品
     * @param setmealId
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id=#{setmealId}")
    List<SetmealDish> getSetMealDishById(Long setmealId);

    /**
     * 根据套餐id查询菜品
     * @param id
     * @return
     */
    @Select("select d.* from dish d join setmeal_dish sd on d.id=sd.dish_id where sd.setmeal_id=#{id}")
    List<Dish> passSetmealIdGetDishInfo(Long id);
}
